package com.wl.controller;

import com.mysql.cj.util.StringUtils;
import com.wl.pojo.model.ReportLabelModel;
import com.wl.response.CommonReturnType;
import com.wl.service.ReportLabelService;
import com.wl.service.impl.ReportLabelServiceImpl;
import com.wl.util.MyUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @program: treeHole
 * @author: 吴磊
 * @create: 2021-07-06 18:54
 */

@WebServlet("/reportLabel.action")
public class ReportLabelServlet extends BaseServlet {

    private ReportLabelService reportLabelService = new ReportLabelServiceImpl();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String op = request.getParameter("op");
        if (StringUtils.isNullOrEmpty(op)) {
            show404Common(request, response);
            return;
        }
        if ("getAllReportLabel".equals(op)) {
            getAllReportLabelOp(request, response);
        } else {
            show404Common(request, response);
        }
    }

    /**
     * 获取所有的举报标签
     *
     * @param request
     * @param response
     */
    private void getAllReportLabelOp(HttpServletRequest request, HttpServletResponse response) throws IOException {
        List<ReportLabelModel> labelModels = reportLabelService.getAllReportLabelOp();
        MyUtil.responseData(response, CommonReturnType.success(labelModels));
    }
}
